package com.architecture.core.dao;

import com.architecture.core.CoreCycleInterface;
import com.architecture.core.entity.BaseEntity;
import org.apache.log4j.Logger;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created with Aguang.
 * LoginAction: Administrator
 * Date: 12-5-7
 * Time: 下午2:30
 * 这一层主要用于持久化的操作，一个实体对应于一个DAO类,参数不合法都会抛出异常
 */
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.REQUIRED, readOnly = true, timeout = 30)
public abstract class AbstractDAO<E extends BaseEntity> implements CoreCycleInterface {
    protected final Logger logger = Logger.getLogger(this.getClass());

    @Resource
    public SessionFactory sessionFactory;

    protected Session getSessioin() {
        return this.sessionFactory.getCurrentSession();
    }


}
